/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * TrainingBook
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TRACK_HPP_
#define _TRACK_HPP_

#include <list>
#include <string>
#include <TrackSegment.hpp>
#include <fstream>

///@class Track
///@brief Define a GPS track in GPX format
class Track
{
    public:
        ///@brief Default constructor
        Track();
        ///@brief Copy constructor
        Track(const Track&);
        ///@brief Desctructor
        ~Track();
        ///@brief Read track from Gpx file
        bool ReadGPX(std::string);
        ///@brief Write track to a Gpx file
        bool WriteGPX(std::string);
        ///@brief Return length of the track
        double Length();
        ///@brief Return total duration
        Duration GetDuration();
        ///@brief Return the start date of the GPX file
        DateTime GetStartDate();
        ///@brief Return total ascent
        double TotalAscent();
        ///@brief Return total descent
        double TotalDescent();
        ///@brief Clear the current track
        void Clear();
        ///@brief Return a list containing the distance value of each point of the track
        std::list<double> GetDistanceList();
        ///@brief Return a list containing the elevation value of each point of the track
        std::list<double> GetElevationList();
        ///@brief Return a list containing the speed value of each point of the track
        std::list<double> GetSpeedList();
        ///@brief Return a list containing the latitude value of each point of the track
        std::list<double> GetLatList();
        ///@brief Return a list containing the longitude value of each point of the track
        std::list<double> GetLonList();
        ///@brief Return minimum value of elevation
        double MinElevation();
        ///@brief Return maximum value of elevation
        double MaxElevation();
        ///@brief Return maximum value of speed
        double MaxSpeed();
        ///@brief Return maximum value of latitude
        double MaxLat();
        ///@brief Return minimum value of latitude
        double MinLat();
        ///@brief Return maximum value of longitude
        double MaxLon();
        ///@brief Return minimum value of longitude
        double MinLon();
        ///@brief Write to XML file
        void WriteXML(std::ofstream&);
        ///@brief Add a new segment to the track
        void AddSegment(TrackSegment);
        ///@brief Test if the track is empty
        bool Empty();
        ///@brief Filter the track by keeping points separated by a given distance, return the number of suppressed points
        unsigned int FilterByDistance(double);
        ///@brief Filter the track by keeping points separated by a given elevation variation
        ///@return Number of suppressed points
        unsigned int FilterByElevationVariation(double);
        ///@brief Smooth the elevation values with given buffer size
        void SmoothElevation(unsigned int);
        ///@brief Recompute the speed values
        void RecomputeSpeed();
        ///@brief Return an iterator to the first segment
        std::list<TrackSegment>::iterator GetFirstSegment();
        ///@brief Write a part of the content of the track to the standard output
        void WriteForDebug();

    protected:

    private:
        std::list<TrackSegment> segments;

};

#endif // _TRACK_HPP_
